using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using Terra.Data.Entities;

namespace Terra.Data.Entities.Identity;

/// <summary>
/// 用户角色关系实体
/// </summary>
[Table("UserRoles")]
[Comment("用户角色关系表")]
public class UserRole : EntityBase<Guid>
{
    /// <summary>
    /// 用户ID
    /// </summary>
    [Required]
    [Comment("用户ID")]
    public Guid UserId { get; set; }

    /// <summary>
    /// 角色ID
    /// </summary>
    [Required]
    [Comment("角色ID")]
    public Guid RoleId { get; set; }

    /// <summary>
    /// 用户
    /// </summary>
    [ForeignKey(nameof(UserId))]
    public virtual User User { get; set; }

    /// <summary>
    /// 角色
    /// </summary>
    [ForeignKey(nameof(RoleId))]
    public virtual Role Role { get; set; }
}